import Vue from 'vue'
import VueRouter from 'vue-router'

// 导航
import Home from '@/components/nav/Home.vue'
import PersonalCenter from '@/components/nav/PersonalCenter.vue'

// 首页
import EpidemicConsultation from '@/components/unBan/EpidemicConsultation.vue'
import EpidemicData from '@/components/unBan/EpidemicData.vue'
import EpidemicKnowledge from '@/components/unBan/EpidemicKnowledge.vue'
import EpidemicNotification from '@/components/unBan/EpidemicNotification.vue'

// 用户通用模块
import PersonalInformation from '@/components/user/common/PersonalInformation.vue'
import Favorites from '@/components/user/common/Favorites.vue'

// 管理员模块
import ClockManageTotal from '@/components/user/adminManage/ClockManageTotal.vue'
import ClockManageToday from '@/components/user/adminManage/ClockManageToday.vue'
import ApplicationManage from '@/components/user/adminManage/ApplicationManage.vue'
import KnowledgeManage from '@/components/user/adminManage/KnowledgeManage.vue'
import NotificationManage from '@/components/user/adminManage/NotificationManage.vue'
import ConsultManage from '@/components/user/adminManage/ConsultManage.vue'
import UserManage from '@/components/user/adminManage/UserManage.vue'

// 普通用户模块
import Application from '@/components/user/normalManage/Application.vue'
Vue.use(VueRouter)

const router = new VueRouter({
  routes: [
    { path: '/', redirect: '/epidemicConsultation' },
    {
      path: '/home', component: Home,
      redirect: '/epidemicConsultation',
      children: [
        { path: '/epidemicConsultation', component: EpidemicConsultation },
        { path: '/epidemicData', component: EpidemicData },
        { path: '/epidemicKnowledge', component: EpidemicKnowledge },
        { path: '/epidemicNotification', component: EpidemicNotification },
        {
          path: '/personalCenter', component: PersonalCenter,
          redirect: '/personalInformation',
          children: [
            { path: '/personalInformation', component: PersonalInformation },
            { path: '/favorites', component: Favorites },
            { path: '/consultManage', component: ConsultManage },
            // {
            //   // path: '/',
            //   // redirect: '/clockManageTotal',
            //   children: [
                { path: '/clockManageTotal', component: ClockManageTotal },
                { path: '/clockManageToday', component: ClockManageToday },
            //   ]
            // },
            { path: '/knowledgeManage', component: KnowledgeManage },
            { path: '/notificationManage', component: NotificationManage },
            { path: '/userManage', component: UserManage },
            { path: '/applicationManage', component: ApplicationManage },
            { path: '/application', component: Application },
          ]
        }
      ]
    }
  ]
})

// router.beforeEach((to, from, next) => {
//   let token = sessionStorage.getItem('token')
//   if (to.path === '/personalInformation') return next()
//   if (!token) return next('/epidemicConsultation')
//   next()
// })
export default router
